'''
Created on Aug 25, 2011

@author: david
'''

from pspy.gae.actiondomain import PspyAction

class Activate(PspyAction):
    """
    Activate an account from mail accept.
    """
    def execute(self): 
        from app.Ranger.agents import AccessAgent
        import logging
        
        req = self.request
        
        # set up
        rslts = "200::Ok"
        nxtPage = "/Ranger/Index.gen"
        c = req.getParameter("c")
        aid = c.split("-")[1].split("_")[0]
        
        logging.info("~~ Activating Account %s" % aid)
        
        AccessAgent().activate(aid)
            
        # all done, return to client
        req.setAttribute("results",rslts)
        req.setResponsePage(nxtPage)    
        return req.getResponse()
    
    def sess_check(self):
        return True